import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:hm_show_flutter/config/application.dart';
import 'package:hm_show_flutter/config/routers.dart';
import 'package:hm_show_flutter/utils/string_util.dart';
import 'package:hm_show_flutter/utils/fluro_convert_util.dart';

class NavigatorUtils {
  static goLogin(BuildContext context) {
    Application.router.navigateTo(context, Routers.login,
        transition: TransitionType.inFromRight);
  }
  static goRegister(BuildContext context) {
    Application.router.navigateTo(context, Routers.register,
        transition: TransitionType.inFromRight);
  }

  static goMallMainPage(BuildContext context) {
    Application.router.navigateTo(context, Routers.home,
        transition: TransitionType.inFromRight, replace: true);
  }

  static goCategoryGoodsListPage(
      BuildContext context, String categoryName, int categoryId, int parentId) {
    var categoryNameText = StringUtils.encode(categoryName);

    Application.router.navigateTo(
        context,
        Routers.categoryGoodsList +
            "?categoryName=$categoryNameText&categoryId=$categoryId&parentId=$parentId",
        transition: TransitionType.inFromRight);
  }

  static goGoodsListPage(BuildContext context) {
    Application.router.navigateTo(context, Routers.goodsList,
        transition: TransitionType.inFromRight);
  }

  static goGoodsDetailPage(BuildContext context, int goodsId) {
    Application.router.navigateTo(
        context, Routers.goodsDetail + "?goodsId=$goodsId",
        transition: TransitionType.inFromRight);
  }

  static goActivityListPage(BuildContext context) {
    Application.router.navigateTo(context, Routers.activityList,
        transition: TransitionType.inFromRight);
  }

  static goActivityDetailPage(BuildContext context, int id) {
    Application.router.navigateTo(context, Routers.activityDetail + "?id=$id",
        transition: TransitionType.inFromRight);
  }

  static goCollectionListPage(BuildContext context) {
    Application.router.navigateTo(context, Routers.collectionList,
        transition: TransitionType.inFromRight);
  }

  static goSettingPage(BuildContext context) {
    Application.router.navigateTo(context, Routers.setting,
        transition: TransitionType.inFromRight);
  }

  static goCompanyListPage(BuildContext context, int type) {
    Application.router.navigateTo(context, Routers.companyList + "?type=$type",
        transition: TransitionType.inFromRight);
  }

  static goCompanyDetailPage(BuildContext context, int id) {
    Application.router.navigateTo(context, Routers.companyDetail + "?id=$id",
        transition: TransitionType.inFromRight);
  }

  static goWebView(BuildContext context, String title, String url) {
    var titleName = FluroConvertUtils.fluroCnParamsEncode(title);
    var urlEncode = FluroConvertUtils.fluroCnParamsEncode(url);

    Application.router.navigateTo(
        context, Routers.webView + "?title=$titleName&&url=$urlEncode",
        transition: TransitionType.inFromRight);
  }

  static goSearchGoods(BuildContext context) {
    Application.router.navigateTo(context, Routers.searchGoods,
        transition: TransitionType.inFromRight);
  }

  static goEditName(BuildContext context) {
    Application.router.navigateTo(context, Routers.editName,
        transition: TransitionType.inFromRight);
  }

  static goMemberList(BuildContext context) {
    Application.router.navigateTo(context, Routers.member,
        transition: TransitionType.inFromRight);
  }

  static goCourseList(BuildContext context) {
    Application.router.navigateTo(context, Routers.courseList,
        transition: TransitionType.inFromRight);
  }

  static goAboutUS(BuildContext context) {
    Application.router.navigateTo(context, Routers.aboutUs,
        transition: TransitionType.inFromRight);
  }

  static goAppointmentList(BuildContext context) {
    Application.router.navigateTo(context, Routers.appointmentList,
        transition: TransitionType.inFromRight);
  }
}
